﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LPLib
{
    public abstract class MonomerPair<T,U>
    {
        public abstract double Mutation(T nuc1, U nuc2);
        public abstract double FirstIsGap(T nuc1);
        public abstract double SecondIsGap(U nuc2);
    }

    public class MNBytePair: MonomerPair<byte, byte>
    {
        public override double Mutation(byte nuc1, byte nuc2)
        {
            return 1 - MixedNucleotideByte.InnerProduct(nuc1, nuc2);
        }

        public override double FirstIsGap(byte nuc1)
        {
            return nuc1 == 16 ? 1 : 0;
        }

        public override double SecondIsGap(byte nuc2)
        {
            return nuc2 == 16 ? 1 : 0;
        }
    }

    public class PMFMNBytePair : MonomerPair<double[], byte>
    {
        public override double Mutation(double[] nuc1, byte nuc2)
        {
            return 1 - NucleotidePMF.IDFlux(nuc1, TypeConverter.ToPMF(nuc2));
        }

        public override double FirstIsGap(double[] nuc1)
        {
            return nuc1[4];
        }

        public override double SecondIsGap(byte nuc2)
        {
            return nuc2 == 16 ? 1 : 0;
        }
    }
}
